﻿using System;
using System.Data;
using System.Data.Common;
using Songhay.Data.Common;

namespace Songhay.Data.GenericWeb.Procedure
{
    /// <summary>
    /// List procedures for Web-schema data.
    /// </summary>
    internal static partial class List
    {
        /// <summary>
        /// Lists all fragments associated with the specified Client ID.
        /// </summary>
        /// <param name="commonConnection">The <see cref="System.Data.Common.DbConnection"/>.</param>
        /// <param name="clientId">The specified Client ID.</param>
        /// <returns>Returns an <see cref="System.Data.Common.DbDataReader"/>.</returns>
        /// <remarks>This member lists the content fragments of a Document.</remarks>
        internal static DbDataReader FragmentsByClientId(DbConnection commonConnection, string clientId)
        {
            using(DbCommand cmd = commonConnection.CreateCommand())
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT * FROM Fragment WHERE ClientId = @ClientId";
                cmd.Parameters.Add(CommonParameter.GetParameter(cmd, "@ClientId", clientId));

                return cmd.ExecuteReader(CommandBehavior.Default);
            }
        }
    }
}
